import Vue from 'vue'

// 默认系统配置
const sysConfig = {

}
// 游客访问的路由
const whitePageList = [
	'/',
	'/pages/index/index',
	'/pages/job/index',
	'/pages/message/index',
	'/pages/ucenter/index',
	'/pages/login/index',
]
// 底部导航栏
const tabBarList = [{
		iconPath: "/template/h5/diy/static/img/tabbar/home.png",
		selectedIconPath: "/template/h5/diy/static/img/tabbar/home-on.png",
		text: '首页',
		count: 0,
		isDot: false,
		customIcon: false,
		pagePath: "/pages/index/index",
	},
	{
		iconPath: "/template/h5/diy/static/img/tabbar/category.png",
		selectedIconPath: "/template/h5/diy/static/img/tabbar/category-on.png",
		text: '分类',
		customIcon: false,
		pagePath: "/pages/category/index",
	},
	{
		iconPath: "/template/h5/diy/static/img/tabbar/msg.png",
		selectedIconPath: "/template/h5/diy/static/img/tabbar/msg-on.png",
		text: '消息',
		customIcon: false,
		pagePath: "/pages/msg/msg",
	},
	{
		iconPath: "/template/h5/diy/static/img/tabbar/user.png",
		selectedIconPath: "/template/h5/diy/static/img/tabbar/user-on.png",
		text: '我的',
		count: 0,
		isDot: false,
		customIcon: false,
		pagePath: "/pages/ucenter/index",
	}
]

export default {
	namespaced: true, // 无需app就能调用
	state: {
		sysConfig,
		whitePageList,
		tabBarList
	},
	mutations: {
		setSystemConfig(state, sysConfig) {
			state.sysConfig = Vue.prototype.$u.deepMerge(state.sysConfig, sysConfig)
		},
		test(state, payload) {
			state.whitePageList.push(payload)
		}
	},
	actions: {
		// 获取系统配置
		async getSystemConfig({
			commit,
			state
		}) {
			const res = await Vue.prototype.$u.api.sysConfig()
			commit('setSystemConfig', res)
		},
		test({
			commit,
			state
		}) {
			commit('test', '/test')
		}
	},
	getters: {
		tabBarNavList: (state) => {
			return state.tabBarList.map(item => item.pagePath)
		}
	},
}